﻿using System;
using System.ComponentModel;

namespace INNOVACALL.Framework.Common.MVCHelpers.Localization
{
    /// <summary>
    /// 
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event)]
    public class DisplayNameLocalizedAttribute : DisplayNameAttribute
    {
        public DisplayNameLocalizedAttribute(Type resourceManagerProvider, string resourceKey)
            : base(CommonLocalization.LookupResource(resourceManagerProvider, resourceKey))
        {
        }
    }
    /// <summary>
    /// Recherche un membre dans la ressource pour les vues
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event)]
    public class DisplayNameLocalizedEntityAttribute : DisplayNameAttribute
    {
        public DisplayNameLocalizedEntityAttribute(Type resourceManagerProvider, string viewName, string entityName, string resourceKey)
            : base(CommonLocalization.LookupResource(resourceManagerProvider, string.Format(@"View_{0}_{1}_{2}", viewName, entityName, resourceKey)))
        {
            var a = string.Format(@"{0}_{1}_{2}", viewName, entityName, resourceKey);
            a = CommonLocalization.LookupResource(resourceManagerProvider, a);
        }

        public DisplayNameLocalizedEntityAttribute(Type resourceManagerProvider, string entityName, string resourceKey)
            : base(CommonLocalization.LookupResource(resourceManagerProvider, string.Format(@"Ety_{0}_{1}", entityName, resourceKey)))
        {
            var a = string.Format(@"{0}_{1}", entityName, resourceKey);
            a = CommonLocalization.LookupResource(resourceManagerProvider, a);
        }

    }
}
